﻿/*
按1的个数排序 
Time Limit:1000MS  Memory Limit:32768K


Description:
有一些01字串，将其按1的个数的多少的顺序进行输出。

Sample Input:
10011111
00001101
1010101
1
0
1100
Sample Output:
0
1
1100
00001101
1010101
10011111
*/

#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;

struct Comparator 
{
public:
	bool operator()(const string& s1, const string& s2)
	{
		const char c='1';
		return 
			count(s1.begin(), s1.end(), c) < count(s2.begin(), s2.end(), c);
	}
};

int main()
{
	vector<string> vs;
	vs.reserve(10);
	
	for (string s;  cin>>s; )
	{
		vs.push_back(s);
	}
	sort(vs.begin(), vs.end(), Comparator());

	copy(vs.begin(), vs.end(), ostream_iterator<string>(cout, "\n"));

	return 0;
}